﻿@using Vega.USiteBuilder
@using SPCFMedicineInformer.DocumentTypes.Base
@using SPCFMedicineInformer.DocumentTypes
@using Fonqi.Umbraco
@using umbraco.NodeFactory

@{            
    var basePage = ContentHelper.GetByNodeId<GlobalBase>(Node.Id).WebsiteContent;
    var homePage = NodeLocator.GetNodeOfExactType<FrontPage>(basePage.Id);
    var contactUsPage = NodeLocator.GetNodeOfExactType<ContactUsPage>(basePage.Id);    
         
}

<div id="templatemo_header_wrapper">
	<div id="templatemo_header">
    	<div id="site_title"></div>
        <div id="templatemo_menu" class="ddsmoothmenu">
            <ul>
                <li><a href="@homePage.Url" class="@IsCurrentNode(homePage.Id, false, false)">@homePage.MenuTitle</a></li>
                <li><a href="about.html">About</a></li>                
                <li><a href="portfolio.html">Gallery</a></li>                
                @if (contactUsPage != null)
                { 
                    <li><a href="@contactUsPage.Url" class="@IsCurrentNode(contactUsPage.Id, false, false)">@contactUsPage.MenuTitle</a></li>
                }
                
            </ul>
            <br style="clear: left" />
        </div> <!-- end of templatemo_menu -->
    </div> <!-- END of templatemo_header -->
</div> <!-- END of templatemo_header_wrapper -->


@functions{
   
    public string IsCurrentNode(int? menuId, bool withClassElement, bool checkChildren)
    {
        if (!menuId.HasValue) return string.Empty;
        var currentId = Node.Id;
        if (checkChildren)
        {
            if (menuId.Value == currentId || NodeController.IsNodeDescendantOfNode(currentId, menuId.Value))
                return withClassElement ? "class=\"selected\"" : "selected";
        }
        else
        {
            if (menuId.Value == Node.Id)
                return withClassElement ? "class=\"selected\"" : "selected";
        }

        return string.Empty;
    }
}    
